$(function(){
	$(document).bind('click',function(e){
		  var e = e || window.event;
		  var elem  = e.target || e.srcElement;
		  while(elem){
		  	if(elem.id && (elem.id == 'inputBox' || elem.id == 'selectBox')){
		  		return;
		  	}
		  	elem = elem.parentNode;
		  }
		  goUp('selectBox');
	});
})

var fruitList = [
                 {"no":"00","name":"苹果"},
                 {"no":"01","name":"橘子"},
                 {"no":"02","name":"梨"},
                 {"no":"03","name":"葡萄"},
                 {"no":"04","name":"甘蔗"},
                 {"no":"05","name":"香蕉"},
                 {"no":"06","name":"葡萄"},
                 {"no":"07","name":"樱桃"},
                 {"no":"08","name":"桃子"},
                 {"no":"09","name":"荔枝"},
                 {"no":"10","name":"猕猴桃"},
                 {"no":"11","name":"西瓜"},
                 {"no":"12","name":"哈密瓜"},
                 {"no":"12","name":"椰子"}
                ]

function initSelect(selectId){
	var i = 0;
	var optionHtml = '';
	for (i = 0;i < fruitList.length; i++){
		optionHtml += '<option value = "'+fruitList[i].no+'">'+ fruitList[i].name +'</option>';
	}
	$('#' + selectId).html(optionHtml);
}

function selectText(selectId,textId){
	var selectValue = $('#' + selectId + ' option:selected').text();
	$('#' + textId).val(selectValue);
	$('#' + selectId).addClass('hide');
}

function goDown(downId){
	$('#' + downId).removeClass('hide');
}  

function goUp(upId){
	$('#' + upId).addClass('hide');
}
